#!/usr/bin/env python
# -*- coding: utf-8 -*-
#(c)Jonathan & Gregoire (read __doc__ for more information)
#Copyright (C)%(author)s (%(date)s)
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

## @packagename PyCol
# PyCol it is a card game, you can play against human player or computer
# PyCol is a french wordplay "picole"
# Objective game's is create most structure, the player who close one structure he wins 1 point
# The winner is the player with the most points


import  sys
import  os
from    engine.controller.Game         import Game
from    engine.view.Game_view          import Game_view

__author__      = \
"""
Jonathan MERCIER <bioinfornatics at gmail.com
Gregoire

"""
__version__     = "$Revision: 0.1 $"
__date__        = "$Date: 2009/23/09$"
__copyright__   = "Copyright (c) 2009 Jonathan MERCIER and Gregoire NAUDIN"
__license__     = "GPL v3 or under"
__name__        = "__main__"
__description__ = \
"""
PyCol it is a card game, you can play against human player or computer
PyCol is a french wordplay "picole"
Objective game's is create most structure, the player who close one structure he wins 1 point
The winner is the player with the most points
"""

## Documentation for Application class
# This class is the main program
class Pycol(object) :

    ## The constructor
    def __init__(self):
        ## Create the view object
        self.__game_view    = Game_view()
        ## Create the pattern object
        self.__game         = Game()
        
    
    ## Private method __menu
    # @brief It is a private method used for print game menu's
    # @param self The object pointer
    # @return: number_human_player and number_computer_player
    def __menu(self):
        number_human_player    = None
        number_computer_player = None
        answer                 = None
        
        while answer < 1 or answer> 3 or answer is None:
            answer = self.__game_view.menu()
            
        if answer == 1:
            ## ask the number of human player
            number_human_player = self.__game_view.ask_number_human_player()
        elif answer == 2:
            ## ask the number of human player
            number_human_player = self.__game_view.ask_number_human_player()
            ## ask the number of computer player
            number_computer_player = self.__game_view.ask_number_computer_player()
        elif answer == 3:
            # Go out of loop while because return 2 None value
             number_human_player    = None
             number_computer_player = None

        return number_human_player,number_computer_player

    ## Public method run
    # It is a public method used for launch the games
    # @param self The object pointer
    def run(self):
        continuer = True
        os.system("clear")
        ## Print a funny smiley
        self.__game_view.logo()

        while continuer:
            # Print the game menu's
            number_human_player,number_computer_player = self.__menu()

            if number_human_player is None and number_computer_player is None:
                # Go out of loop while because they are 2 None value
                continuer = False
                print u"Good Bye"
            else:
                self.__game.run(number_human_player,number_computer_player)
    

if __name__ =="__main__":
    pycol = Pycol()
    pycol.run()

    sys.exit(0)
